package com.study.ju.service;

import com.alibaba.fastjson.JSON;
import com.study.ju.model.req.CreateTemplateReq;
import com.study.ju.model.res.CreateTemplateRes;
import com.study.ju.service.mybatistest.Mybatistest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:spring/spring-service.xml"})
public class MybtisJunitTest2 {
    @Autowired
    private Mybatistest mybatistest;
    @Test
    public void qryCreateTemplateTest(){
        CreateTemplateReq req = new CreateTemplateReq();
        req.setQryInteger(1);
        //req.setQryInteger(2);
        List<CreateTemplateRes> createTemplateRes = mybatistest.qryCreateTemplate(req);
        System.out.println(JSON.toJSONString(createTemplateRes));
    }
    @Test
    public void update(){
        CreateTemplateReq req = new CreateTemplateReq();
        req.setRownum(1L);
        req.setSerialno("1111");
        mybatistest.update(req);
    }
    @Test
    public void qryAllByConditionTest(){
        List<String> strings = new ArrayList<>();
        strings.add("1");
        List<CreateTemplateRes> createTemplateRes = mybatistest.qryAllByCondition(strings, "20180718", "");
        System.out.println("結果："+JSON.toJSONString(createTemplateRes));
    }
    @Test
    public void qryParamlist(){
        CreateTemplateReq req = new CreateTemplateReq();
        req.setQryStr("20180718");
        List<String> strings = new ArrayList<>();
        strings.add("1");
        List<CreateTemplateRes> createTemplateRes = mybatistest.qryParamlist(strings, req);
        System.out.println("結果："+JSON.toJSONString(createTemplateRes));
    }
}
